<?php

/**
 * @author Murat Cem YALIN <muratcem@gmail.com>
 * @copyright 2014 muratcem.com - walkerPHP.com
 * @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3
 * @version 1.0.1
 */

namespace core\Model;

interface IModel{

    /**
     * fetching records from table of model
     *
     * @param string $orderBy
     * @param array $filter
     * @return array
     */
    public function fetchAll($orderBy = '', $filter = array());

    /**
     * find records from the table of model
     * similar to fetchAll returns array on multiple result
     * except returns $this on single record
     *
     * @return $this|array
     */
    public function find();

    /**
     * try to save new record by using class variables
     * id variable will set with PDO::lastInsertId()
     *
     * @return bool
     */
    public function save();

    /**
     * try to update the record in table by using class variables
     * where clauses will be created with $$updateFieldBy
     *
     * @param string $updateFieldBy
     * @return bool
     */
    public function update($updateFieldBy = '');

    /**
     * try to delete record in table by ysing $deleteFieldBy fieldname
     * and its value
     *
     * @param string $deleteFieldBy
     * @return mixed
     */
    public function delete($deleteFieldBy = '');
}